package com.benben.springSecurity.weiwei;

public class MatrixTransfer {
    public static void main(String[] args) {
      int[][] input = new int[][]{{3,7,1},{2,4,0},{9,4,2}};
      int[][] output = transFer(input);
      for (int i=0;i<output.length;i++){
          for(int j=0;j<output[0].length;j++){
              System.out.print(output[i][j]);
          }
          System.out.println();

      }
    }
    public static int[][] transFer(int[][] inputMatrix){
        int[][] outputMatrix = new int[inputMatrix.length][inputMatrix[0].length];
        for(int i=0;i<inputMatrix.length;i++){
            for(int j=0;j<inputMatrix[0].length;j++){
                outputMatrix[i][j] = sum(inputMatrix,i,j);
            }
        }
        return outputMatrix;
    }
    public static int sum(int[][] inputMatrix,int indexRol,int indexCol){
       int sum = 0;
       for(int i=0;i<=indexRol;i++){
           for(int j=0;j<=indexCol;j++){
               sum += inputMatrix[i][j];
           }
       }
       return sum;
    }
}
